
# 1.print(s[::-1])
# 2.print(s.count('t'))
# 3.
# s1=s.replace(' ','_')
# print(s1)

# 4. 检查回文: 检查字符串`s2 = "A man, a plan, a canal, Panama!"` 在忽略大小写、标点和空格的情况下是否为回文字符串。
#回文（Palindrome）是一种无论正向还是反向读取都相同的字符串
# s2 = "A man, a plan, a canal, Panama!"
# s1="".join(x for x in s2 if x.isalnum()).lower()
# print(s1)
# result=s1==s1[::-1]
# print(result)
# 5.
# index=s.find("is")
# print(index)
#
# # 6.
# index=s.find('t')
# if index == -1:  #未找到
#     print("Not found")
# else:
#     s1=s[0:index]+'_inserted'+s[index:]
# print(s1)
# 7.

# first_index =s.find("great")
# s1=s[:first_index]+'awesome'+s[first_index+5:]
# print(s1)
# 8.
# 预处理：移除所有非字母数字字符
# s1 = ''.join(x for x in s if x.isalnum())
# length=len(s)
# mid=length//2
# # 切片：前半部分和后半部分
# first_half = s[:mid]
# second_half = s[mid:]
# result = second_half + first_half
# print(f"原始字符串: {s}")
# print(f"处理后的字符串: {s}")
# print(f"反转拼接结果: {result}")

# 9.
# result=[]
s = "Python is great great!"
# s1=s.split(" ")
# # result=[x.capitalize() for x in s1]
# for x in s1:
#     result.append(x.capitalize())
#
# print(result)
#
# s = "Python is great great!"
# result=[x.capitalize() for x in s.split(" ")]
# print(result)
#
#
# s = "hello world, python programming"
# words_capitalize = [word.capitalize() for word in s.split()]
# print(f"方法2结果: {words_capitalize}")

# 10.
# 10. 字符替换加密: 编写一个函数`encrypt`，
# 使用字典 `a: m, b: n, ... z: l}`
# 的对应规则加密字符串`s3 = "encryption"`。